﻿using System;
using System.Web.UI;

namespace AnalogClock.Controls.AnalogClock
{
    public partial class AnalogClock : System.Web.UI.UserControl
    {
        private int gmt = 0;

        public string GMT
        {
            get
            {
                if (gmt > 0)
                {
                    return "+" + gmt;
                }
                return gmt.ToString();
            }
            set
            {
                this.gmt = int.Parse(value);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Page_Prerender(object sender, EventArgs e)
        {
            LoadScripts();
        }

        private void LoadScripts()
        {
            ClientScriptManager cs = Page.ClientScript;
            string jQueryUrl = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";

            if (!cs.IsStartupScriptRegistered(jQueryUrl))
            {
                cs.RegisterClientScriptInclude(jQueryUrl, jQueryUrl);
            }

            string clockEngine = this.TemplateSourceDirectory +
                                 "/Scripts/coolclock.js";
            if (!cs.IsStartupScriptRegistered(clockEngine))
            {
                cs.RegisterClientScriptInclude(clockEngine, clockEngine);
            }

            string clockSkins = this.TemplateSourceDirectory +
                                "/Scripts/moreskins.js";
            if (!cs.IsStartupScriptRegistered(clockSkins))
            {
                cs.RegisterClientScriptInclude(clockSkins, clockSkins);
            }
        }
    }
}